home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97a.txt
/
000138_icon-group-sender _Thu Jun 12 17:53:32 1997.msg
< prev
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Received: from kingfisher.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Mon, 16 Jun 1997 08:43:02 MST
Received: by kingfisher.CS.Arizona.EDU; (5.65v3.2/1.1.8.2/08Nov94-0446PM)
id AA10747; Mon, 16 Jun 1997 08:43:02 -0700
Date: Thu, 12 Jun 1997 17:53:32 -0400
Message-Id: <199706122153.RAA05260@axp.cmpu.net>
Mime-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: gep2@computek.net
Subject: Re: searching with variables
To: icon-group@cs.arizona.edu
X-Mailer: SPRY Mail Version: 04.00.06.17
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1644
>> A quick question. If you wanted to use the function find() to search for
> a particular strings of characters, how would it be possible to define
> character variables? For example, suppose you want to search for the
> following sequences
>
> al
> el
> il
> ol
> ul
>
> which are really just Vl (where V stands for a vowel). Could you simply
> define a character set for vowels (V := 'aeiou') and then refer to that
> character set in the find() function? If so, what would it look like? I
> tried something like the following and it didn't work.
>
> find( V || "l")
>
> I realise it's a pretty trivial task but I don't have the manual at the
> moment and I'd like an answer within the next couple of days. Thanks in
> advance.
>Well you don't (want to use find()).
Function find() only matches substrings.
>Try this (based on "The Icon Programming Language" (1983), p 177):
procedure Vl(line)
static vowel
local line, i
initial vowel := 'aeiou'
i := 1
while i := upto(vowel,line,i) do {
suspend line[i+:2]
i += 2
}
end
>procedure testVl()
local line
while line := read() do {
every write(Vl(line))
}
end
This is another example of where SNOBOL4/SPITBOL is easier and simpler and more
direct than Icon.
In SNOBOL4 one can simply use:
&TRIM = 1
PAT = FENCE (BREAKX("aeiou") LEN(1) "l") $ OUTPUT FAIL
RDLOOP LINE = INPUT :F(END)
LINE PAT :F(RDLOOP)
END
Gordon Peterson
http://www.computek.net/public/gep2/
Support the Anti-SPAM Amendment! Join at http://www.cauce.org/